<?php
/**
 * 会员控制器
 * Created by Forever. 
 * User: Forever
 * Date: 2018/10/03 
 * Time: 上午 10:39
 */
namespace app\api\controller;
use think\Controller;
use think\Request; 
use \think\db;
use think\Validate;
class Member extends Base{
	public function _initialize() {
	  parent::_initialize (); 
	}

 /*
 *个人中心
 */
  public function memberCenter(){
    $data = $this->data; 
    $check = $this->validate($data,'Member.detail');
    if($check !==true){
       return api_return($check);
    }
    $result = model('Member')->getMemberDetail($data);
    if($result != false ){
        return api_return(10002,$result);
    }else{
        return api_return(-10002);
    }
  }


  public function memberDetail(){
    $data = $this->data; 
    $check = $this->validate($data,'Member.follow');
    if($check !==true){
       return api_return($check);
    }
    $result = model('Member')->MemberDetail($data);
    if($result != false ){
        return api_return(10002,$result);
    }else{
        return api_return(-10002);
    }
  }

 /*
 * 店铺列表
 */
  public function shop_list(){
    $data = $this->data; 
    $check = $this->validate($data,'Member.shop_list');
    if($check !==true){
      return api_return($check);
    }
    //model处理信息
    $result = model('Member')->getShopList($data);
    if($result != false ){
      return api_return(10002,$result);
    }else{
      return api_return(-10002);
    }
   }

 /*
 * 店铺详情
 */
  public function shop_detail(){
    $data = $this->data; 
    $check = $this->validate($data,'Member.shop_detail');
    if($check !==true){
      return api_return($check);
    }
    //model处理信息
    $result = model('Member')->getShopDetail($data);
    if($result != false ){
      return api_return(10002,$result);
    }else{
      return api_return(-10002);
    }
  }
 

 /*
 * 店铺车辆列表
 */
  public function shop_car_list(){
    $data = $this->data; 
    $check = $this->validate($data,'Member.shop_detail');
    if($check !==true){
      return api_return($check);
    }
    //model处理信息
    $result = model('Member')->getShopCarList($data);
    if($result != false ){
      return api_return(10002,$result);
    }else{
      return api_return(-10002);
    }
  }
 

 /*
 *店铺收藏列表
 */
  public function shopFollow(){
    $data = $this->data; 
    $check = $this->validate($data,'Member.follow');
    if($check !==true){
       return api_return($check);
    }
    $result = model('Member')->getShopFollow($data);
    return api_return(10002,$result);
  }

 /*
 * 车辆收藏列表
 */
  public function carFollow(){
    $data = $this->data; 
    $check = $this->validate($data,'Member.follow');
    if($check !==true){
       return api_return($check);
    }
    $result = model('Member')->getCarFollow($data);
    return api_return(10002,$result);
  }

  /*
   * 浏览历史
   */
  public function getBrowsing(){
    $data = $this->data; 
    $check = $this->validate($data,'Member.follow');
    if($check !==true){
       return api_return($check);
    }
    $result = model('Member')->getBrowsing($data);
    return api_return(10002,$result);
  }
 

  /*
   * 收藏店铺
   */
  public function shop_follow(){
    $data = $this->data; 
    $check = $this->validate($data,'Member.shop_follow');
    if($check !==true){
       return api_return($check);
    }
    $result = model('Member')->followShop($data);
    if($result == false && $result>0){
      return api_return(10001);  
    }else{
      return api_return($result);  
    } 
  }
 
}

